import json
# import urllib2.urlopen
from urllib2 import urlopen
from scrapyd import webservice

# if __name__ == '__main__':
class webspiderlist():
    def render(self):
        # web_server    = 'http://10.0.2.2:8080'
        f = urlopen('http://localhost:6800/listspiders.json?project=test1')
        a = json.load(f)
        haha =  a['spiders'][1]
        s = '''
<html>
<head><title>Scrapyd</title></head>
<body>
<h1>Scrapyd</h1>
<ul>

<li><a href="/logs/">%s</a></li>

</ul>
</body>
</html>

                ''' %haha

        return s

# if __name__ == '__main__':
#     # haha = webspiderlist()
#
#     f = urlopen('http://localhost:6800/listspiders.json?project=test1')
#     a = json.load(f)
#     print a   # a =  haha.render()
#     # print a
